package com.ruoyi.app.controller.dict;

import com.ruoyi.app.business.dict.DictBusiness;
import com.ruoyi.common.core.utils.CommonUtils;
import com.ruoyi.common.core.web.domain.APIResult;
import com.ruoyi.common.core.web.page.CommonPageInfo;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.service.dict.model.DictModel;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 字典控制器
 *
 * @author Zane
 * @since 2025-10-04
 */
@RestController
@RequestMapping("/dict/")
public class DictController {

  @Resource
  private DictBusiness dictBusiness;

  /**
   * 根据字典类型获取字典列表
   *
   * @param dictType 字典类型 岗位:post  项目类型:projectType
   * @return 字典列表
   */
  @GetMapping("list/{dictType}")
  public TableDataInfo<DictModel> getPageByType(@PathVariable("dictType") String dictType,
      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
    CommonPageInfo<DictModel> list =dictBusiness.getPageByType(dictType);
    return CommonUtils.buildTableData(list);
  }

  /**
   * 根据字典类型获取字典列表[不分页]
   *
   * @param dictType 字典类型 岗位:post  项目类型:projectType
   * @return 字典列表
   */
  @GetMapping("listNoPage/{dictType}")
  public APIResult<List<DictModel>> getListByType(@PathVariable("dictType") String dictType) {
    List<DictModel> list =dictBusiness.getListModelByType(dictType);
    return APIResult.success(list);
  }

}
